import { getOrderSearchAPI,postaddOderAPI,postOrderStateAPI} from "../../api/userinfo"
const order = {
  state: {
    orderInfo: {
    }, //用户订单基本信息
  },

  mutations: {
    //保存订单基本信息
    SET_ORDERINFO(state: any, value: any) {
      state.orderInfo = value;
    },
  },

  actions: {
    async SET_ORDERINFO(content: any, id:any) {
    return new Promise(async (resolve, reject)=>{
      await getOrderSearchAPI({
        uid:id,
      }).then((res: any) => {
        resolve(res.data);
        content.commit("SET_ORDERINFO", res.data)
        console.log(res.data);
      })
    })
    },
    async SET_ADDORDER(content: any, param:any) {
      return new Promise(async (resolve)=>{
        await postaddOderAPI(param).then((res)=>{
            resolve(res.data)
        })
      })
      },
       //修改订单状态
    async SET_ORDERSTATE(content: any, param:any) {
      return new Promise(async (resolve, reject)=>{
        await postOrderStateAPI(param).then((res: any) =>{
          console.log(res.data);
          resolve(res.data)
        })
      })
      },
}
}
export default order;